﻿using System.Collections.Generic;
using System.Collections.ObjectModel;
using TeaLightV5.Foundation.Sal.Interfaces;
using TeaLightV5.Foundation.UX.Interfaces.Models;

namespace TeaLightV5.Foundation.UX.ViewModels
{
    public class BaseEntityViewModelObservableCollection<T, TE, TV, TKey>
        : ObservableCollection<TV>
        , IObservableCollection<TV>
        where T : IEntityModel<TE, TKey>, new()
        where TE : class, IEntity<TKey>, new()
        where TV : BaseEntityViewModel<T, TE, TKey>, new() 
    {
        public BaseEntityViewModelObservableCollection()
        { 
        }

        public BaseEntityViewModelObservableCollection(IEnumerable<TE> source)
        {
            // todo
            foreach (var entity in source)
            {
                TV viewModel = new TV();
                T model = new T();
                viewModel.Data = model;
                model.SetFrom(entity);
                Add(viewModel);
            }
        }

        //public EntityObservableCollection(IEnumerable<T> source)
        //    : base(source)
        //{            
        //}
    }


  
}
